package gbackup.command;


import gbackup.core.Shell;

import java.io.PrintStream;
import java.util.LinkedList;
import java.util.List;
import java.util.StringTokenizer;


public abstract class Command {
	protected Shell _shell = null;
	protected String _rawCommand = null;
	protected String _command = null;
	protected List<String> _arguments = null;
	protected PrintStream _outputPrintStream = null;

	public Command(Shell shell, String rawCommand) {
		this._shell = shell;
		this._rawCommand = rawCommand;
		this._arguments = new LinkedList<String>();
		this._outputPrintStream = new PrintStream(this._shell.getOutputStream(), true);

		StringTokenizer st = new StringTokenizer(rawCommand, " \t");
		if (st.hasMoreTokens())
			this._command = st.nextToken();
		while (st.hasMoreTokens()) {
			this._arguments.add(st.nextToken());
		}
	}

	public abstract void execute();
}
